#ecoding: utf-8 -*-

from quixote import get_request, get_response, redirect, get_cookie, get_session
from pynixweb.template.template import render_template
from pynixweb.controllers.controller import PynixWebController

class IndexController(PynixWebController):
    def index(self):
        name = get_cookie("login_name")
        print "hello"
        get_session().user = {}
        get_session().user["username"] = "abc"
        if name!=None:
            messages = []
            messages.append("你的名字"+name)
        return render_template("example/index.html", locals())

    def login(self):
        name = get_request().get_field("name")
        print get_session().user
        get_response().set_cookie('login_name', name)
        redirect("/example/")